#ifndef _USART_APP_H_
#define _USART_APP_H_

#pragma pack(1)

struct usart_tx_info {
    unsigned int   len;
    unsigned char *data;
};

#define USART_RX_BUF_LEN (512)

struct usart_rx_buf_info {
    unsigned int  head;
    unsigned int  tail;
    unsigned char data[USART_RX_BUF_LEN];
};

#define CMD_FRAME_BUF_LEN (3072)

struct usart_cmd_info {
    unsigned int   cursor;
    unsigned short frame_len;
    unsigned char  frame_buf[CMD_FRAME_BUF_LEN];
};

struct request_data_pack {
    unsigned int       start;
    unsigned char      co_ver;
    unsigned short     len;
    unsigned char      src;
    unsigned char      dst;
    unsigned long long rsvd;
    unsigned short     cmd_info;
    unsigned short     page_id;
    unsigned int       check_sum;
    unsigned int       end;
};

struct update_result_pack {
    unsigned int       start;
    unsigned char      co_ver;
    unsigned short     len;
    unsigned char      src;
    unsigned char      dst;
    unsigned long long rsvd;
    unsigned short     cmd_info;
    unsigned char      result;
    unsigned int       check_sum;
    unsigned int       end;
};

#pragma pack()

void usart_send_process(void *arg);
void init_usart_var(void);
void usart_test(void *arg);

void usart_rx_process(void);
void request_data_process(void);
void uart_send(unsigned char *data, unsigned int num);

extern struct usart_cmd_info usart_cmd_data;

extern unsigned char usart_start;

extern unsigned char update_ph;

#endif
